/*
 * $Id$
 *
 * Copyright (c) 2011 Qunar.com. All Rights Reserved.
 */
package com.qunar.upd.support;

import java.io.File;

import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.springframework.beans.factory.InitializingBean;

import com.qunar.base.meerkat.util.StringUtil;

/**
 * {@link DiskFileItemFactory}支持类
 * 
 * @author zhongyuan.zhang
 */
public class DiskFileItemFactorySupport extends DiskFileItemFactory implements InitializingBean {

    /**
     * 临时目录
     */
    private String repository;

    public void setRepository(String repository) {
        this.repository = repository;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        if (!StringUtil.isEmpty(repository)) {
            super.setRepository(new File(repository));
        }
    }
}